package com.shen.langchain4j.config;

import com.shen.langchain4j.service.ChatAssistant;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 大模型配置类
 */

@Configuration
public class LLMConfig {
    @Bean(value = "qwen")
    public ChatModel chatLanguageModelQwen() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("aliyunQwen-apiKey"))
                .modelName("qwen3-next-80b-a3b-instruct")
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }

    @Bean(value = "deepseek")
    public ChatModel chatLanguageModelDeepseek() {
        return OpenAiChatModel.builder()
                .apiKey(System.getenv("DeepSeek-apiKey"))
                .modelName("deepseek-chat")
                .baseUrl("https://api.deepseek.com/v1")
                .build();
    }

    @Bean
    public ChatAssistant chatAssistant(@Qualifier(value = "qwen") ChatModel chatModel) {
        return AiServices.create(ChatAssistant.class, chatModel);
    }

}
